<?php
namespace app\admin\middleware;
class CheckLogin{
    
    public function handle($request, \Closure $next)
    {
        //前置中间键
        $userData = session(config('admin.session_user'));
        if(empty($userData) && (!preg_match('/login/',$request->pathinfo()))){
            return redirect(url('login/index'));
        }
        $response = $next($request);
        //后置中间键
//        if(empty($userData) && ($request->controller() != 'Login')){
//            return redirect(url('login/index'));
//        }
        return  $response;
    }

    public function end(\think\Response $response)
    {
        // 回调行为
    }
    
}
